<?php

namespace Modules\Shop\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Modules\Shop\Entities\Article;

class SearchController extends Controller
{
    /**
     * Display a listing of the resource.
     * @return Response
     */
    public function index(Request $request)
    {
    	if($request->ajax ()){
			$key=$request->input('search');
			$data=Article::where('title','like','%'.$key.'%')->orderBy('created_at','desc')->get();
			return json_encode ($data);
		}

    }
}
